package com.ayue.clinet.mqspringboot.consumer.delay;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.support.AmqpHeaders;
import org.springframework.messaging.handler.annotation.Headers;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;

/**
 * @author yuelinbo
 * @date 2020/3/25 17:57
 **/
@Component
//@RabbitListener(queues = "delay.queue")
public class DelayConsumer {

//    @RabbitHandler
//    public void simpleConsume(@Payload String message, @Headers Map<String, Object> headers, Channel channel) {
//        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//        System.out.println(sdf.format(new Date()) + "延时队列模式：consumer----" + message);
//        try {
//            channel.basicAck((Long) headers.get(AmqpHeaders.DELIVERY_TAG), true);
//        } catch (IOException e) {
//            e.printStackTrace();
//        }
//
//
//    }
}
